//
//  BNDHomeCardHelper.m
//  OfficeDoc
//
//  Created by pie on 2022/4/8.
//  Copyright © 2022 pie. All rights reserved.
//

#import "BNDHomeCardHelper.h"
#import "BNDOfficeDoHomeCell.h"
#import "BNDChooseCompanyHelper.h"
#import "BNDOfficeDocModel.h"
#import "BNDPushVCHandler.h"
#import "LVDownLoadManager.h"


@interface BNDHomeCardHelper()<UITableViewDelegate,UITableViewDataSource,TableViewHelperDelegate>

@end

@implementation BNDHomeCardHelper

- (instancetype)initWith:(UITableView *)tableView
{
    if((self = [super initWith:tableView]) != nil) {
        self.tableView.delegate = self;
        self.tableView.dataSource = self;
        self.delegate = self;
    }
    return self;
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.datas.count;
}

- (BNDOfficeDoHomeCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    static NSString *Identifier = @"BNDOfficeDoHomeCell";
    BNDOfficeDoHomeCell *cell = [tableView dequeueReusableCellWithIdentifier:Identifier];
    if (!cell) {
        cell = [[BNDOfficeDoHomeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Identifier];
    }
   cell.model = self.datas[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    
//    BNDOfficeDocModel *model = self.datas[indexPath.row];
//    [BNDPushVCHandler pushOfficeDocDetailsVc:model];
}

- (CGFloat)tableView:(nonnull UITableView *)tableView heightForRowAtIndexPath:(nonnull NSIndexPath *)indexPath
{
    return 99;
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    [[BNDPushVCHandler topViewController].view endEditing:YES];
}


#pragma mark -网络数据请求入口

- (void)load:(int)page tableView:(UITableView *)tableView
{
    

    @weakify(self)
    [BNDApiManager officeDocRequestAnnouncementCard:^(NSArray<BNDOfficeDocModel *> * _Nonnull moreClass) {
        @strongify(self)
        [self finish:moreClass errcode:0 inView:self.tableView];
    } failure:^(NSError * _Nullable error) {
        @strongify(self)
        [self finish:nil errcode:1 inView:self.tableView];
    }];
}

//- (void)setKeyWord:(NSString *)keyWord
//{
//    _keyWord = keyWord;
//    [self reload];
//}
@end
